//
//  Transaction.swift
//  jiaoyi
//
//  Created by 易万军 on 2018/10/21.
//  Copyright © 2018 wjk. All rights reserved.
//

import Foundation
import ObjectMapper

//"id": 3163,
//"effect": 100000,
//"direction": 3,
//"business_type": 3,
//"abstract": "从委托方预冻结履约保证金",
//"contract_id": null,
//"contract_no": null,
//"operation_time": "2018-10-11 13:59:15"

struct Transaction: Mappable {
    var id: Int?
    var effect: Int?
    var direction: Int?
    var business_type: Int?
    var abstract: String?
    var contract_id: Int?
    var contract_no: String?
    var operation_time: String?
    
    
    init?(map: Map) {
        
    }
    // Mappable
    mutating func mapping(map: Map) {
        id                  <- map["id"]
        effect              <- map["effect"]
        direction           <- map["direction"]
        business_type       <- map["business_type"]
        abstract            <- map["abstract"]
        contract_id         <- map["contract_id"]
        contract_no         <- map["contract_no"]
        operation_time      <- map["operation_time"]
    }
    
    func directionAbstract() -> String{
        guard let dir = direction else {
            return ""
        }
        switch dir {
        case 1:
            return "收入"
        case 2:
            return "支出"
        default:
            return "内转"
        }
    }
}


